import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;

public class Sender {
    private static Sender sender;
    private Socket socket;
    private PrintWriter printWriter;
    private static String[] IPS;
    private static String[] PORTS;

    private Sender() throws IOException {
        IPS = Utilbll.getProperty("RECEIVE_IP").split(",");
        PORTS = Utilbll.getProperty("RECEIVE_PORT").split(",");
    }

    public static Sender getInstance() throws IOException {
        if (sender == null) {
            sender = new Sender();
        }
        return sender;
    }

    public void send(String str) {
        this.printWriter.println(str);
    }

    public void connect(int n) throws IOException {
        this.socket = new Socket(IPS[n], Integer.parseInt(PORTS[n]));
        this.printWriter = new PrintWriter(socket.getOutputStream(),true);
    }
}
